<template>
  <div class="app-container" style="padding-top: 40px;">
    <el-row class="title">
      <el-col :span="12" style="text-align: left;">
        <el-button @click="$refs.AddModal.open = true" round>新建分组</el-button>
      </el-col>
      <el-col :span="12" style="text-align: right;">
        <el-button round type="primary ">创建审批流程</el-button>
      </el-col>
    </el-row>
    <a-spin :spinning="loading" class="page">
      <el-card class="box-card card_option" style="padding: 0px;">
        <div slot="header" class="clearfix">
          <span>通用审批流程模板</span>
          <!--<a-button class="add_btn" @click="goAdd">新增审批模板</a-button>-->
        </div>
        <approval-group :isCanDelete="false" :records="listData" />
      </el-card>
    </a-spin>
    <add-form ref="AddModal" />
  </div>
</template>

<script>
  import ApprovalGroup from './components/ApprovalGroup'
  import AddForm from './components/AddModal'
  import { list } from '@/pages/views/approval/service'

  export default {
    name: 'Home',
    data() {
      return {
        activeName: 'first',
        loading: false,
        listData: []
      }
    },
    methods: {
      goAdd() {
        this.$router.push({ path: '/approver' })
      },
      handleClick() {
        this.initList()
      },
      initList() {
        this.loading = true
        const type = this.activeName === 'first' ? '1' : '2'
        list({ customerId: this.$store.getters.customerId, type }).then(res => {
          this.listData = res.data
          this.loading = false
        })
      }
    },
    created() {
      this.initList()
    },
    components: {
      AddForm,
      ApprovalGroup
    }
  }
</script>
<style lang="stylus" scoped>
  $header-height = 54px;
  .title {
    text-align: right;
    margin 10px auto;
    max-width 1200px;
  }

  .page {
    width: 100%;
    height: 100%;
    box-sizing: border-box;

    .page__header {
      width: 100%;
      height: $header-height;
      flex-center()
      justify-content: space-between;
      box-sizing: border-box;
      color: white;
      background: #3296fa;
      font-size: 14px;
      position: fixed;
      top: 0;

      .page-actions {
        height: 100%;
        text-align: center;
        line-height: $header-height;

        > div {
          height: 100%;
          padding-left: 20px;
          padding-right: 20px;
          display: inline-block;
        }

        i {
          font-size: 22px;
          vertical-align: middle;
        }
      }

      .step-tab {
        display: flex;
        justify-content: center;
        height: 100%;
        position: relative;

        > .step {
          width: 140px;
          line-height: $header-height;
          padding-left: 30px;
          padding-right: 30px;
          cursor: pointer;
          position: relative;

          &.ghost-step {
            position: absolute;
            height: $header-height;
            left: 0;
            z-index: -1;
            background: #4483f2;
            transition: transform .5s;

            &::after {
              content: '';
              border-width: 6px 6px 6px;
              border-style: solid;
              border-color: transparent transparent white;
              position: absolute;
              bottom: 0;
              left: 50%;
              margin-left: -6px;
            }
          }

          &.active > .step-index {
            background: white;
            color: #4483f2;
          }

          > .step-index {
            display: inline-block;
            width: 18px;
            height: 18px;
            border: 1px solid #fff;
            border-radius: 8px;
            line-height: 18px;
            text-align: center;
            box-sizing: border-box;
          }
        }
      }
    }

    .page__content {
      width: 100%;
      height: 100%;
      overflow: hidden;
      box-sizing: border-box;
      background #f5f5f7
    }
  }

  .publish-btn {
    margin-right: 20px;
    color: #3296fa;
    padding: 7px 20px;
    border-radius: 4px;
    font-size: 14px;
  }

  .github {
    position fixed
    bottom 10px
    left 20px
  }

  .card_option {
    margin 0 auto
    width: 100%;
    max-width: 1200px;
  }

  .add_btn {
    float: right;
  }
</style>
